﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Navigation;
using System.Collections.ObjectModel;

namespace BidiControls_Tester.Views
{
  public partial class Arabic : Page
  {
    public Arabic()
    {
      InitializeComponent();
    }

    // Executes when the user navigates to this page.
    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
    }

    private void btnFillSimple_Click(object sender, RoutedEventArgs e)
    {
      ObservableCollection<string> data = new ObservableCollection<string>();
      data.Add("البند رقم 1");
      data.Add("البند رقم 2");
      data.Add("البند رقم 3");
      data.Add("البند رقم 4");
      data.Add("البند رقم 5");
      data.Add("البند رقم 6");
      data.Add("البند رقم 7");
      data.Add("البند رقم 8");
      data.Add("البند رقم 9");
      data.Add("البند رقم 10");

      if (null == lstBidiListBox.ItemsSource)
        lstBidiListBox.Items.Clear();
      lstBidiListBox.ItemsSource = data;
      lstBidiListBox.ItemTemplate = LayoutRoot.Resources["bidiSimpleData"] as DataTemplate;


      if (null == lstListBox.ItemsSource)
        lstListBox.Items.Clear();
      lstListBox.ItemsSource = data;
      lstListBox.ItemTemplate = LayoutRoot.Resources["nonBidiSimpleData"] as DataTemplate; ;
    }

    private void btnFillComplex_Click(object sender, RoutedEventArgs e)
    {
      ObservableCollection<ComplexData> data = new ObservableCollection<ComplexData>();

      data.Add(new ComplexData() { FirstName = "اليكس", LastName = "نكون", Birthday = new DateTime(1973, 12, 14), ID = 100000000 });
      data.Add(new ComplexData() { FirstName = "أحمد", LastName = "أحمد", Birthday = new DateTime(1975, 10, 1), ID = 200000000 });
      data.Add(new ComplexData() { FirstName = "محمد", LastName = "محمد", Birthday = new DateTime(1981, 5, 22), ID = 300000000 });
      data.Add(new ComplexData() { FirstName = "سليمان", LastName = "سليمان", Birthday = new DateTime(1970, 1, 13), ID = 400000000 });
      data.Add(new ComplexData() { FirstName = "عباس", LastName = "عباس", Birthday = new DateTime(1982, 10, 5), ID = 500000000 });

      if (null == lstBidiListBox.ItemsSource)
        lstBidiListBox.Items.Clear();
      lstBidiListBox.ItemTemplate = LayoutRoot.Resources["bidiComplexData"] as DataTemplate;
      lstBidiListBox.ItemsSource = data;


      if (null == lstListBox.ItemsSource)
        lstListBox.Items.Clear();
      lstListBox.ItemTemplate = LayoutRoot.Resources["nonBidiComplexData"] as DataTemplate;
      lstListBox.ItemsSource = data;
    }

    private void btnFillDataGrids_Click(object sender, RoutedEventArgs e)
    {
      ObservableCollection<ComplexData> data = new ObservableCollection<ComplexData>();

      data.Add(new ComplexData() { FirstName = "اليكس", LastName = "نكون", Birthday = new DateTime(1973, 12, 14), ID = 100000000 });
      data.Add(new ComplexData() { FirstName = "أحمد", LastName = "أحمد", Birthday = new DateTime(1975, 10, 1), ID = 200000000 });
      data.Add(new ComplexData() { FirstName = "محمد", LastName = "محمد", Birthday = new DateTime(1981, 5, 22), ID = 300000000 });
      data.Add(new ComplexData() { FirstName = "سليمان", LastName = "سليمان", Birthday = new DateTime(1970, 1, 13), ID = 400000000 });
      data.Add(new ComplexData() { FirstName = "عباس", LastName = "عباس", Birthday = new DateTime(1982, 10, 5), ID = 500000000 });

      grdBidiDataGrid.ItemsSource = data;
      grdDataGrid.ItemsSource = data;
    }
  }
}
